package dtt;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
	public static Connection getConnection(){
		Connection con = null;
		try {
			if(false){
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				con = DriverManager.getConnection("jdbc:odbc:accessdsn");
	
			}else
			{
				Class.forName("oracle.jdbc.driver.OracleDriver");
				con = DriverManager.getConnection("jdbc:oracle:thin:hongtao/all4one@127.0.0.1:1521/XE","hongtao","all4one");
				if (con == null)
				{
					System.out.println("driver manager is down");
				}
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}

		return con;
	}
	
	public static void releaseConnection(Connection con)
	{
		try
		{
			con.close();
		}
		catch(SQLException e) {
			e.printStackTrace();			
		}
	}

}
